<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h3>new Vue 组件</h3>
        <!-- <comp></comp> -->
        <comp-a></comp-a>
        <comp-a></comp-a>
        <comp-a></comp-a>
        <hr>
        <!-- <compb></compb> -->
        <comp-b></comp-b>
    </div>

    <template id="compb"> 
        <div>
            <h3>组件3</h3>
            <p>msg:{{msg}}</p>
            <input type="text" v-model="msg">
            <input type="button" value="弹框" @click="showAlert()">
            <hr>
            <comp-a></comp-a>
        </div>
    </template>
</body>
<script>
    var CompA = Vue.extend({
        template:"<h1>info:{{info}}</h1>",
        data(){
            return{
                info:"compA的页面模板"
            }
        },
        beforeCreate() {
            console.log("compA组件实例被创建")
        },
    })

    Vue.component("CompA",CompA);

    Vue.component("CompB",{
        template:"#compb",
        data(){
            return {
                msg:"默认数据"
            }
        },
        methods: {
            showAlert(){
                alert("showAlert")
            }
        },
    })


    new Vue({
        el:"#app"
    })
</script>
</html>